package src.Base;

import java.util.HashMap;

public class SymbolTable {
    String FuncName = null;
    public static SymbolTable globelTable = new SymbolTable();
    public SymbolTable Father = null;
    HashMap<String, Symbol> name_symbol = new HashMap<>();
    private boolean isLoop = false;
    private boolean needReturn = false;
    public SymbolTable getFather(){return Father;}
    public boolean exist(String name){
        return name_symbol.containsKey(name);
    }
    public Symbol getSymbol(String name){
        return name_symbol.getOrDefault(name, null);
    }
    public void addSymbol(String name,Symbol tmp){
        name_symbol.put(name, tmp);
    }
    public String getFName(){
        return FuncName;
    }
    public void setFuncName(String s){
        this.FuncName = s;
    }
    public void setIsLoop(boolean flag){
        isLoop = flag;
    }
    public boolean getIsLoop(){
        return isLoop;
    }

    public boolean isNeedReturn() {
        return needReturn;
    }

    public void setNeedReturn(boolean needReturn) {
        this.needReturn = needReturn;
    }

    public int getSymbolCount(){
        return name_symbol.size();
    }
}
